package geez.widget;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.MenuBar;

import static geez.widget.Geez.withStyle;

public class GMenuBar extends MenuBar implements GWidget {

    public GMenuBar() {
    }

    public GMenuBar(MenuBarImages menuBarImages) {
        super(menuBarImages);
    }

    public GMenuBar(boolean vertical) {
        super(vertical);
    }

    public GMenuBar(boolean vertical, MenuBarImages menuBarImages) {
        super(vertical, menuBarImages);
    }

    public GMenuBar addMenuItem(GMenuItem menuItem) {
        super.addItem(menuItem);
        return this;
    }

    public GMenuBar addSubMenuItem(String label, GMenuBar subMenu) {
        GMenuItem item = new GMenuItem(label, subMenu);
        item.id(DOM.getElementAttribute(subMenu.getElement(), "id"));
        item.css(subMenu.getStylePrimaryName());
        super.addItem(item);
        return this;
    }

    public GMenuBar addSeparator(GMenuItemSeparator separator) {
        super.addSeparator(separator);
        return this;
    }

    public GMenuBar removeItem(GMenuItem menuItem) {
        super.removeItem(menuItem);
        return this;
    }

    public GMenuBar removeSeparator(GMenuItemSeparator separator) {
        super.removeSeparator(separator);
        return this;
    }

    public GMenuBar id(String id) {
        Geez.withNameAndId(this, id);
        return this;
    }

    public GMenuBar css(String cssClass, String... optionalClasses) {
        withStyle(this, cssClass, optionalClasses);
        return this;
    }

    public GMenuBar title(String title) {
        setTitle(title);
        return this;
    }

    public GMenuBar show() {
        setVisible(true);
        return this;
    }

    public GMenuBar hide() {
        setVisible(false);
        return this;
    }

    public GMenuBar width(String value) {
        setWidth(value);
        return this;
    }

    public GMenuBar height(String value) {
        setHeight(value);
        return this;
    }

}
